/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cse308.helper_classes;

import cse308.General;
import cse308.GeneralEntity;
import cse308.entities.Altcoursecoordinators;
import cse308.entities.Courseinfo;
import cse308.entities.Courseoutcome;
import cse308.entities.Degreeprogram;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author dwysocki
 */
public class CourseClass implements GeneralTest{

    private String coursename;
    private String identifier;
    private String coursecoordinator;
    private Map<String, String> degreePrograms = new HashMap();
    private Map<String, String> altCourseCoordinators = new HashMap();
    private Map<String, String> courseOutcomes = new HashMap();
    private String degreeProgram;
    private String altCourseCoordinator;
    private String courseOutcome;
    
    /*
        associatedEntities.add(Degreeprogram.class.getCanonicalName());
        associatedEntities.add(Courseoutcome.class.getCanonicalName());
        associatedEntities.add(Altcoursecoordinators.class.getCanonicalName());
     */
    
    private List<String> ownDegreePrograms = new ArrayList();
    private List<String> allDegreePrograms = new ArrayList();
    private Map<String,General> degreeProgramsMap = new HashMap();
    
    private List<String> ownCourseOutcomes = new ArrayList();
    private List<String> allCourseOutcomes = new ArrayList();
    private Map<String,General> courseOutcomesMap = new HashMap();
    
    private List<String> ownAltCourseCoordinators = new ArrayList();
    private List<String> allAltCourseCoordinators = new ArrayList();
    private Map<String,General> altCourseCoordinatorsMap = new HashMap();
            
            
    public CourseClass() {
    }

    public CourseClass(Courseinfo entity) {
        this.coursename = entity.getCoursename();
        this.identifier = entity.getIdentifier();
        this.coursecoordinator = entity.getCoursecoordinator();
      //  Collection<Altcoursecoordinators> altList=entity.getAltcoursecoordinatorsCollection();
        Collection<Degreeprogram> dpList=entity.getDegreeprogramCollection();
        //Collection<Courseoutcome> coList =entity.getCourseoutcomeCollection();
        //for(Altcoursecoordinators alt : altList){
          //  this.altCourseCoordinators.put(alt.getIdentifier2(), alt.getIdentifier2());
        //}
        for(Degreeprogram dp : dpList){
            this.degreePrograms.put(dp.getIdentifier2(), dp.getIdentifier2());
        }
        //for(Courseoutcome co : coList){
          //  this.courseOutcomes.put(co.getIdentifier2(), co.getIdentifier2());
        //}
        
    }

    public String getDegreeProgram() {
        return degreeProgram;
    }

    public void setDegreeProgram(String degreeProgram) {
        this.degreeProgram = degreeProgram;
    }

    public String getAltCourseCoordinator() {
        return altCourseCoordinator;
    }

    public void setAltCourseCoordinator(String altCourseCoordinator) {
        this.altCourseCoordinator = altCourseCoordinator;
    }

    public String getCourseOutcome() {
        return courseOutcome;
    }

    public void setCourseOutcome(String courseOutcome) {
        this.courseOutcome = courseOutcome;
    }

    public String getCoursename() {
        return coursename;
    }

    public void setCoursename(String coursename) {
        this.coursename = coursename;
    }

    public String getIdentifier() {
        return identifier;
    }

    public void setIdentifier(String identifier) {
        this.identifier = identifier;
    }

    public String getCoursecoordinator() {
        return coursecoordinator;
    }

    public void setCoursecoordinator(String courseCoordinator) {
        this.coursecoordinator = courseCoordinator;
    }

    public Map<String, String> getDegreePrograms() {
        return degreePrograms;
    }

    public void setDegreePrograms(Map<String, String> degreePrograms) {
        this.degreePrograms = degreePrograms;
    }

    public Map<String, String> getAltCourseCoordinators() {
        return altCourseCoordinators;
    }

    public void setAltCourseCoordinators(Map<String, String> altCourseCoordinators) {
        this.altCourseCoordinators = altCourseCoordinators;
    }

    public Map<String, String> getCourseOutcomes() {
        return courseOutcomes;
    }

    public void setCourseOutcomes(Map<String, String> courseOutcomes) {
        this.courseOutcomes = courseOutcomes;
    }

    public List<String> getOwnDegreePrograms() {
        return ownDegreePrograms;
    }

    public void setOwnDegreePrograms(List<String> ownDegreePrograms) {
        this.ownDegreePrograms = ownDegreePrograms;
    }

    public List<String> getAllDegreePrograms() {
        return allDegreePrograms;
    }

    public void setAllDegreePrograms(List<String> allDegreePrograms) {
        this.allDegreePrograms = allDegreePrograms;
    }

    public Map<String, General> getDegreeProgramsMap() {
        return degreeProgramsMap;
    }

    public void setDegreeProgramsMap(Map<String, General> degreeProgramsMap) {
        this.degreeProgramsMap = degreeProgramsMap;
    }

    public List<String> getOwnCourseOutcomes() {
        return ownCourseOutcomes;
    }

    public void setOwnCourseOutcomes(List<String> ownCourseOutcomes) {
        this.ownCourseOutcomes = ownCourseOutcomes;
    }

    public List<String> getAllCourseOutcomes() {
        return allCourseOutcomes;
    }

    public void setAllCourseOutcomes(List<String> allCourseOutcomes) {
        this.allCourseOutcomes = allCourseOutcomes;
    }

    public Map<String, General> getCourseOutcomesMap() {
        return courseOutcomesMap;
    }

    public void setCourseOutcomesMap(Map<String, General> courseOutcomesMap) {
        this.courseOutcomesMap = courseOutcomesMap;
    }

    public List<String> getOwnAltCourseCoordinators() {
        return ownAltCourseCoordinators;
    }

    public void setOwnAltCourseCoordinators(List<String> ownAltCourseCoordinators) {
        this.ownAltCourseCoordinators = ownAltCourseCoordinators;
    }

    public List<String> getAllAltCourseCoordinators() {
        return allAltCourseCoordinators;
    }

    public void setAllAltCourseCoordinators(List<String> allAltCourseCoordinators) {
        this.allAltCourseCoordinators = allAltCourseCoordinators;
    }

    public Map<String, General> getAltCourseCoordinatorsMap() {
        return altCourseCoordinatorsMap;
    }

    public void setAltCourseCoordinatorsMap(Map<String, General> altCourseCoordinatorsMap) {
        this.altCourseCoordinatorsMap = altCourseCoordinatorsMap;
    }

    @Override
    public ArrayList<Map<String, General>> getMap() {
        ArrayList<Map<String, General>> maps = new ArrayList();
        maps.add(this.degreeProgramsMap);
        maps.add(this.courseOutcomesMap);
        maps.add(this.altCourseCoordinatorsMap);
        return maps;
    }

    @Override
    public ArrayList<List<String>> getList() {
        ArrayList<List<String>> lists = new ArrayList();
        lists.add(this.ownDegreePrograms);
        lists.add(this.ownCourseOutcomes);
        lists.add(this.ownAltCourseCoordinators);
        return lists;
    }

    @Override
    public GeneralEntity findCorrespondingEntity() {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("CSE_308_ABETPU");
        EntityManager em = emf.createEntityManager();
        return em.find(Courseinfo.class, this.identifier);
    }

    @Override
    public String getIdentifier2() {
        return this.identifier;
    }

    @Override
    public boolean equalsEntity(GeneralEntity entity) {
        if(entity instanceof Courseinfo){
            Courseinfo ci = (Courseinfo) entity;
            if(ci.getIdentifier().equals(this.identifier)){
                return true;
            }
        }
        return false;
    }   
}